﻿using Mes.Domain.BoundedContext.Entities.Operations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.Operations
{
    public class ProcessEntityConfig : IEntityTypeConfiguration<Process>
    {
        public void Configure(EntityTypeBuilder<Process> builder)
        {
            builder.ToTable("process");
            builder.HasKey(b => b.Process_Id);
            builder.Property(b => b.Process_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Process_Class_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Process_Ver_Id).HasMaxLength(40);
            builder.Property(b => b.Process_Desc).HasMaxLength(80).IsRequired();
            builder.Property(b => b.Process_Level).IsRequired();
            builder.Property(b => b.Process_Status).IsRequired();
            builder.Property(b => b.Creator).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Approver).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Created_At).IsRequired();
            builder.Property(b => b.Last_User_To_Change_Status).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Status_Change_At).IsRequired();
            builder.Property(b => b.Checked_Out_By).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Instantiated).IsRequired();
            builder.Property(b => b.Disassembly).IsRequired().HasDefaultValue(false);
            builder.Property(b => b.May_Override_Route).IsRequired().HasDefaultValue(false);
            builder.Property(b => b.Rework).IsRequired().HasDefaultValue(false);
            builder.Property(b => b.Notes);
            builder.Property(b => b.Spare1).HasMaxLength(80);
            builder.Property(b => b.Spare2).HasMaxLength(80).IsRequired();
            builder.Property(b => b.Spare3).HasMaxLength(80).IsRequired();
            builder.Property(b => b.Spare4).HasMaxLength(80).IsRequired();
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254).IsRequired();
            builder.Property(b => b.Last_Editor).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Mod_Id).IsRequired();
            builder.Property(b => b.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
